ad2c

Section: User Commands (1)
Updated: 19 Apr 1993
Index Return to Main Contents
 

NAME

ad2c - convert resource files to C declarations  

SYNOPSIS

ad2c [ files ]  

DESCRIPTION

Ad2c converts X resource files into C declarations, appropriate for inclusion as fallback resources. The program is a sed(1) script which is effectively a finite state machine, escaping quotes and backslashes (and newlines where necessary), and adding quotes and commas as needed for array initialization.

It reads from the given files (or stdin if none are given) and writes the C declarations to stdout.  

USAGE

The following example shows a typical use of ad2c to ensure that an application always has the latest version of its resources compiled into the executable. Suppose the application defaults file is named "Foobar.ad", for application foobar. Then the following lines in a Makefile or Imakefile will indicate how and when to run ad2c:

    Foobar.ad.h: Foobar.ad
            ad2c Foobar.ad >Foobar.ad.h

The resulting C strings should be included (say in "foobar.c"):

    static char fallback_resources[] = {
        #include "Foobar.ad.h"
        NULL
    };

This array of strings can then be given as a parameter to XtAppInitialize(3X) or otherwise used to initialize the application's resources. Running makedepend or adding the line

    foobar.c: Foobar.ad.h

to the Makefile or Imakefile will ensure that "foobar.c" is recompiled when necessary (ie., whenever "Foobar.ad" changes).  

RETURN VALUE

Ad2c returns as for sed.  

SEE ALSO

sed(1)  

DISCLAIMER

This software is provided as is with no warranty expressed or implied. I hope you find it useful, but I won't be held responsable for any damage that may occur from reading, compiling, installing or using it.

You are free to use any part of this code for other purposes. It would be nice if you could keep my name on some part of whatever the final product is.  

AUTHOR

George Ferguson, ferguson@cs.rochester.edu.

Man page by Joseph Beckenbach, jerbil@ultra.com. Usage section added by George Ferguson. Example corrected by Tim Theisen, tim@cs.wisc.edu. Example further corrected by David Wojtowicz, davidw@vista.atmos.uiuc.edu.

Modified to work with Gnu and IBM sed by Charles Hannum, mycroft@gnu.ai.mit.edu.


 

Index

NAME
SYNOPSIS
DESCRIPTION
USAGE
RETURN VALUE
SEE ALSO
DISCLAIMER
AUTHOR

This document was created by man2html, using the manual pages.
Time: 20:43:48 GMT, June 11, 2022